package com.itheima.web.controller;


import com.itheima.domain.db.UserStatus;
import com.itheima.web.manager.UserManagementManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.Map;

@RestController
public class UserManagementController {


    @Autowired
    private UserManagementManager userManagementManager;

    @PostMapping("/manage/users/freeze")
    public ResponseEntity userStatus(@RequestBody UserStatus userStatus) throws ParseException {

        return userManagementManager.userStatus(userStatus);
    }

    @PostMapping("/manage/users/unfreeze")
    public ResponseEntity unUserStatus(@RequestBody Map<String, String> param) {
        Integer userId = Integer.valueOf(param.get("userId"));
        String reasonsForThawing = param.get("reasonsForThawing");
       return userManagementManager.unUserStatus(userId, reasonsForThawing);
    }

}
